"""Definition of the Prevecion content type
"""

from zope.interface import implements, directlyProvides

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

from guegue.alcaldias import alcaldiasMessageFactory as _
from guegue.alcaldias.interfaces import IPrevecion
from guegue.alcaldias.config import PROJECTNAME

PrevecionSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
    atapi.StringField('title',
                searchable=1,
                isMetadata=0,
                accessor='Title',
                widget=atapi.StringWidget(label='Nombre',
                                      maxlength=150,
                                      size=30,
                                      label_msgid="label_entry_title",
                                      description_msgid="help_entry_title",
                                      i18n_domain="guegue.alcaldias",
                                      description='')),
    atapi.StringField('description',
                searchable=1,
                isMetadata=0,
                accessor='Description',
                widget=atapi.TextAreaWidget(label='Texto Descriptivo',
                                      label_msgid="label_entry_description",
                                      description_msgid="help_entry_description",
                                      i18n_domain="guegue.alcaldias",
                                      description='Entre una breve descripción')),
    atapi.TextField('riesgos',
                searchable=1,
                required=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Riesgos',
                                      label_msgid="label_entry_riesgos",
                                      description_msgid="help_entry_riesgos",
                                      i18n_domain="guegue.alcaldias",
                                      description='')),
    atapi.TextField('acciones',
                searchable=1,
                required=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Acciones',
                                      label_msgid="label_entry_acciones",
                                      description_msgid="help_entry_acciones",
                                      i18n_domain="guegue.alcaldias",
                                      description='Acciones a seguir')),
    atapi.TextField('entidades',
                searchable=1,
                required=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Entidades Involucradas',
                                      label_msgid="label_entry_entidades",
                                      description_msgid="help_entry_entidades",
                                      i18n_domain="guegue.alcaldias",
                                      description='Entidades Involucradas')),
    atapi.TextField('contactos',
                searchable=1,
                required=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Contactos de Emergencia',
                                      label_msgid="label_entry_contactos",
                                      description_msgid="help_entry_contactos",
                                      i18n_domain="guegue.alcaldias",
                                      description='Teléfonos / Contactos de Emergencia de la Entidades involucradas')),
    atapi.TextField('lugares',
                searchable=1,
                required=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Lugares de Refugio',
                                      label_msgid="label_entry_lugares",
                                      description_msgid="help_entry_lugares",
                                      i18n_domain="guegue.alcaldias",
                                      description='')),
    atapi.FileField('adjunto',
              searchable=0,
              required=0,
              widget=atapi.FileWidget(label='Archivo adjunto',
                                label_msgid="label_entry_body",
                                description_msgid="help_entry_adjunto",
                                i18n_domain="guegue.alcaldias",
                                description='Puede adjuntar un archivo con el plan completo.')),
    atapi.TextField('body',
              searchable=1,
              required=0,
              primary=1,
              default_content_type='text/html',
              default_output_type='text/html',
              allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
              widget=atapi.RichWidget(label='Otras consideraciones del Plan',
                                label_msgid="label_entry_body",
                                description_msgid="help_entry_body",
                                i18n_domain="guegue.alcaldias",
                                description="")),
))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

#PrevecionSchema['title'].storage = atapi.AnnotationStorage()
#PrevecionSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(PrevecionSchema, moveDiscussion=False)

class Prevecion(base.ATCTContent):
    """Tipo de datos para prevencion de desastres"""
    implements(IPrevecion)

    portal_type = "Prevecion"
    schema = PrevecionSchema

    #title = atapi.ATFieldProperty('title')
    #description = atapi.ATFieldProperty('description')

atapi.registerType(Prevecion, PROJECTNAME)
